select * from rclisval where abrval ='461E06';
select * from rclisval where zone_id ='2011101062569459877986043';
select * from rczone where zone_id ='2013032237299141691136034';
select * from rcressource;
select * from postpla;
select * from poste;
select * from rcvalzon WHERE zone_id ='2013032237299141691136034';
SELECT a.matricule, libressource1, libressource2, libval, max(B.datfin) 
         FROM rcressource A
         INNER JOIN rcvalzon B on A.matricule = B.matricule
         INNER JOIN rclisval C on B.valeur = C.codval
         WHERE B.zone_id = '2013032237299141691136034'
         GROUP BY A.matricule,libressource1,libressource2,datfin;
         
SELECT libval FROM rcressource A 
              INNER JOIN rcvalzon B on A.matricule = B.matricule 
              INNER JOIN rclisval C on B.valeur = C.codval 
              WHERE B.zone_id = '2011101062569459877986043' AND A.matricule = '01235' ORDER BY datdeb desc;
              
select sal.matricule, sal.libressource1, sal.libressource2, max(post.datpla), poste.libposte, abs.datdeb, abs.datfin
                             from tbabsenc abs inner join rcressource sal on abs.matricule = sal.matricule
                             inner join postpla post on post.matricule = abs.matricule
                             inner join poste poste on poste.codposte = post.codposte  
                         WHERE abs.datdeb <= to_date('2013-11-25', 'YYYY-MM-DD') and datfin >= to_date('2014-04-30','YYYY-MM-DD')
                        and 
                        col01 = 'RM2000'
                        and
                        post.matricule = '02051'
                        group by sal.matricule, sal.libressource1, sal.libressource2, post.datpla, poste.libposte, abs.datdeb, abs.datfin 
                        ;
select * from tbabsenc abs 
         inner join rcressource sal on abs.matricule = sal.matricule
         and abs.datdeb <= to_date('2014-02-11', 'YYYY-MM-DD') and abs.datfin >= to_date('2014-03-15','YYYY-MM-DD')
         order by abs.DATDEB desc ;  

select * from postpla post inner join poste poste on poste.codposte = post.codposte
         where matricule = '00141'
         order by DATPLA asc 
         ;
          
SELECT comp.codcompet, comp.libcompet,comp.codcla, datdeb, datfin FROM gcmatcom mat INNER JOIN gccompet comp on mat.codcompet = comp.codcompet WHERE mat.matricule = '01166' ORDER BY codcla;                     
SELECT count(1) as compteur,  FROM gcmatcom mat INNER JOIN gccompet comp on mat.codcompet = comp.codcompet 
    group by mat.matricule;

select  distinct(abs.matricule), abs.codabs, post.datpla, poste.libposte, col01, sal.libressource1, sal.libressource2, abs.datdeb, abs.datfin
                             from tbabsenc abs inner join rcressource sal on abs.matricule = sal.matricule
                             left join postpla post on post.matricule = abs.matricule
                             inner join poste poste on poste.codposte = post.codposte  
                        WHERE abs.datdeb <= to_date('2014-03-11', 'YYYY-MM-DD') and datfin >= to_date('2014-03-11','YYYY-MM-DD')
                        and
                        col01 = 'ADS-RMPV'
                        order by abs.codabs, sal.libressource1;



select abs.matricule, abs.codabs, sal.libressource1, sal.libressource2, abs.datdeb, abs.datfin 
from tbabsenc abs 
inner join rcressource sal on abs.matricule = sal.matricule 
WHERE abs.datdeb <= to_date('2014-03-11', 'YYYY-MM-DD') 
and datfin >= to_date('2014-03-11','YYYY-MM-DD') 
order by abs.codabs, sal.libressource1;

select * from postpla post inner join poste on poste.codposte = post.codposte 
WHERE post.matricule = '01428';

select libposte from postpla
inner join poste poste on poste.codposte = postpla.codposte 
where matricule = '00164'
and postpla.datpla <= to_date('2014-03-11', 'YYYY-MM-DD')
order by datpla desc;

select perso.matricule, nom, prenom, nosecu,  poste.codposte, poste.libposte, min(post.datpla)
as mindate, max(post.datpla) as maxdate, count(*) as compteur
from perso
inner join postpla post on post.matricule = perso.matricule
inner join poste on poste.codposte = post.codposte 
group by perso.matricule, nom, prenom, nosecu, poste.libposte,poste.codposte
order by nom, mindate;

select perso.matricule, nom, prenom, nosecu, poste.libposte, poste.codposte, post.datpla 
from perso
inner join postpla post on post.matricule = perso.matricule
inner join poste on poste.codposte = post.codposte 
where perso.matricule = '01881';


select pers.matricule, nom, prenom, nosecu, poste.libposte, max(post.datpla), min(post.datpla) 
from perso pers
inner join postpla post on post.matricule = pers.matricule
inner join poste poste on poste.codposte = post.codposte 
inner join postpla post2 on post2.matricule = pers.matricule
group by pers.matricule, nom, prenom, nosecu, poste.libposte
order by post.datpla asc;


